import XCTest
@testable import OpenAISwift

final class OpenAISwiftTests: XCTestCase {
    func testExample() throws {
        // This is an example of a functional test case.
        // Use XCTAssert and related functions to verify your tests produce the correct
        // results.
        let exp = self.expectation(description: "myExpectation")
        exp.isInverted = true
                
        let openai = OpenAISwift(authToken: "")
        
        openai.sendImages(with: "美女",completionHandler:{ result in
            switch result {
            case .success(let model):
                let output = model.data.first?.url ?? ""
                print(output)
                break
            case .failure(let error):
                print("请求失败：请在右上角配置APIKEY；错误信息：" + error.localizedDescription.description)
                break
            }
        })

//        openai.sendCompletion(with: "hello", maxTokens: 1000 ,completionHandler: { result in
//            switch result {
//            case .success(let model):
//                let output = model.choices.first?.text ?? ""
//                print("请求成功：" + output)
//            case .failure(let error):
//                print("请求失败：请在右上角配置APIKEY；错误信息：" + error.localizedDescription.description)
//                break
//            }
//        })
        wait(for: [exp], timeout: 20.0)
//        waitForExpectations(timeout: 10)
    }
}
